﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace Microfinance_Management
{
    public partial class Pay_back : Form
    {
        private string m_id;
        public Pay_back(string id)
        {
            m_id = id;
            InitializeComponent();
        }

        unsafe private void button1_Click(object sender, EventArgs e)
        {
            int loan_num;
            int amount;
            listView1.View = View.Details;
            StringBuilder start_date = new StringBuilder(30);
            StringBuilder due_date = new StringBuilder(30);
            StringBuilder check_date = new StringBuilder(30);
            int i =0;
            string cust_id = textBox1.Text;
            if (cust_id == "")
            {
                MessageBox.Show("请输入客户ID");
                return;
            }
            Payment_dll.startGetLoan(cust_id);
            listView1.Items.Clear();
            while (Payment_dll.GetLoan( &loan_num, start_date, due_date,check_date,&amount))
            {
                listView1.Items.Add(loan_num.ToString());
                listView1.Items[i].SubItems.Add(start_date.ToString());
                listView1.Items[i].SubItems.Add(due_date.ToString());
                listView1.Items[i].SubItems.Add(amount.ToString());
                listView1.Items[i].SubItems.Add(check_date.ToString());
                ++i;
            }
            if (i == 0)
            {
                MessageBox.Show("该客户无贷款");
                this.DialogResult = DialogResult.Cancel;
            }
           
        }

        private void button2_Click(object sender, EventArgs e)
        {
       //     string loan_num = listView1.SelectedItems[0].Text;
         //   NewPayment new_pay = new NewPayment(m_id,loan_num);
           // new_pay.ShowDialog();
        }

        private void pictureBox2_Click(object sender, EventArgs e)
        {

        }

        private void pictureBox1_Click(object sender, EventArgs e)
        {

        }

        private void label1_Click(object sender, EventArgs e)
        {

        }

        private void button3_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.Cancel;
        }
    }
}
